<template>
	<view>
		<view class="top">
			<view style="font-size: 32rpx;">余额</view>
			<view class="" style="font-size: 60rpx;margin-top: 30rpx;">
				￥{{menony}}
			</view>
			
			
			<view style="position: fixed;right: 20rpx;top: 20rpx;"> 
				<u-button @click="goRecord" size="mini" shape="circle" type="success">提现记录</u-button>
			</view>
		</view>


		<view
			style="border-radius:50rpx;position: relative;bottom: 50rpx;width: 750rpx;background: #fff;padding-top: 50rpx;">
			<u-cell-group :border="false">
				<!-- <u-cell-item title="提现方式" :value="way" @click="wayShow=true"></u-cell-item> -->
				<u-cell-item title="提现金额" :arrow="false" hover-class="none">
					<input placeholder="请输入提现金额" v-model="tixianMenony" type="digit" />
				</u-cell-item>
			<!-- 	<u-cell-item title="提现账户" :arrow="false" hover-class="none">
					<input placeholder="请输入提现账户" v-model="accout" />
				</u-cell-item>
 -->
				<u-cell-item title="收款码" hover-class="none" :arrow="false" value="请上传收款二维码" :border-bottom="false"
					v-if="way!=='请先选择提现方式'">

				</u-cell-item>

				<view style="width: 250rpx;height: 500rpx;margin:40rpx auto;text-align: center;" v-if="way!=='请先选择提现方式'"
					@click="">
					
					<upload_img ref="videoUpload" type="image" :afterLoadUrl="imageUrl" defaultLength="1" width="250"
						hight="200" icontxt="微信码" cutType="imageUrl" v-if="way=='微信'"></upload_img>

					<upload_img ref="videoUpload1" type="image" :afterLoadUrl="imageUrl1" defaultLength="1" width="250"
						hight="200" icontxt="支付宝码" cutType="imageUrl1" v-if="way=='支付宝'"></upload_img>

				</view>
			</u-cell-group>
		</view>


		<view class="bottomFix" @click="submit">立即提现</view>

		<u-action-sheet :list="wayList" v-model="wayShow" @click="clickway"></u-action-sheet>

		<u-toast ref="uToast" />
		
		<state ref='mask' :icon='mask.icon' :iconcolor='mask.iconcolor' tags=' '
		
				:content="mask.content" @ready='ready'></state>
		
	</view>
</template>

<script>
	import upload_img from '../../components/upload_img.vue';
import state from '../../components/state.vue'
			
	export default {
		components: {
			upload_img,
state
		},
		data() {
			return {
				mask:{
					iconcolor:"",
					icon:"",
					content:"",
				},
				menony: "",
				way: "请先选择提现方式",
				wayShow: false,
				wayList: [{
						text: '支付宝',
					},
					{
						text: '微信',
					}
				],
				tixianMenony: "",
				accout: "",
				imageUrl: '',
				imageUrl1: "",
                ismanage:true

			}
		},
		onLoad(options) {
			if(options.ismanage){
				this.ismanage=false
			}
		},
		onShow() {

			this.jiazai()


		},

		methods: {
			
			
			
			jiazai() {
                
				this.$u.post(this.ismanage?'/api/alliance/info':'/api/Financial/info', {

				}).then(res => {
                     
					this.menony = this.ismanage?res.balance:res.commission;
				}).catch(err => {

				})


			},
			clickway(e) {
				this.way = this.wayList[e].text;
				
				
				
				this.$u.post('/api/alliance/info', {
				
				}).then(res => {
					this.imageUrl1 = e ? '' : res.alipayQr;
					this.imageUrl = e ? res.wxQr : '';
					this.accout = e ? res.wxName : res.alipayName;
				}).catch(err => {
				
				})
				
				
				
			
			},
			goRecord(){
				uni.navigateTo({
					url:'/pages/fenxiao/list?ismanage='+this.ismanage
				})
			},
			submit() {

				// if (this.way == "请先选择提现方式") {
				// 	this.$u.toast("请先选择提现方式")
				// 	return
				// }
				// if (!this.menony) {
				// 	this.$u.toast("请输入提现金额")
				// 	return
				// }
				// if (!this.accout) {
				// 	this.$u.toast("请输入提现账户")
				// 	return
				// }
				// if (this.way == '微信' ? !this.$refs.videoUpload.afterUploadImgList[0] : !this.$refs.videoUpload1
				// 	.afterUploadImgList[0]) {
				// 	this.$u.toast("请上传收款二维码")
				// 	return
				// }

				this.$u.post(this.ismanage?'/api/alliance/withdraw':'/api/Financial/withdraw', {
					money: this.tixianMenony,
					// type: this.way == "支付宝" ? 2 : 1,
					// name: this.accout,
					// qr: this.way == '微信' ? this.$refs.videoUpload.afterUploadImgList[0] : this.$refs.videoUpload1
					// 	.afterUploadImgList[0]
				}).then(res => {
					this.mask.iconcolor= '#10A9A1'
					this.mask.icon= 'hourglass-half-fill'
					this.mask.content= '请等待客服审核~！'
					this.$refs.mask.show = true

				}).catch(err => {
					if(err.data.msg=='您的余额不足'){
						this.mask.iconcolor= '#2B62BD'
						this.mask.icon= 'rmb-circle'
						this.mask.content= '余额不足~！'
						this.$refs.mask.show = true
						this.$refs.mask.show = true
					}
                      
				})






			}
		}
	}
</script>

<style>
	.top {
		background: #3464D6;
		height: 250rpx;
		padding: 30rpx;
		color: #FFFFFF;
	}

	.bottomFix {
		background: #3154D2;
		color: #fff;
		height: 100rpx;
		text-align: center;
		line-height: 100rpx;
		z-index: 999;
		width: 750rpx !important;
		bottom: 0;
		left: 0;
	}
</style>
